import request from '@/utils/request'

export function getDepartments() {
  return request({
    url: '/company/department',
    method: 'GET'
  })
}

/**
 *
 * code	     部门编码，同级部门不可重复
 * introduce 介绍
 * manager   负责人名称
 * name	     部门名称
 * pid	     父级部门ID
 */
export function addDepartment(data) {
  return request({
    url: '/company/department',
    method: 'POST',
    data
  })
}

export function getDepartmentDetailById(id) {
  return request({
    url: '/company/department/' + id,
    method: 'GET'
  })
}
// 编辑
export function editDepartment(data) {
  return request({
    url: '/company/department/' + data.id,
    method: 'PUT',
    data
  })
}

// 删除
export function deleteDepartment(id) {
  return request({
    url: '/company/department/' + id,
    method: 'DELETE'
  })
}

// 类型： 添加(POST + data), 详情(GET + id), 修改(PUT|patch + id + data),删除(DELETE + id)
//      PUT: 全量修改, PATCH: 局部修改
//      var obj = { a: 1, b:2}, 要求把 a--> 100
//      (1) obj.a = 100          局部
//      (2) obj = {a:100, b:2}   全量

